//package com.weixin.engine.filter;
//
//import com.alibaba.fastjson.JSONObject;
//import com.weixin.common.core.doman.Result;
//import org.springframework.core.MethodParameter;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.http.server.ServerHttpRequest;
//import org.springframework.http.server.ServerHttpResponse;
//import org.springframework.util.CollectionUtils;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
//import org.springframework.lang.Nullable;
//
//import java.util.Set;
//import java.util.stream.Collectors;
//
///**
// * 自定义返回值拦截器
// *
// * @author wangchunhui
// * @date 2022/4/28 20:43
// */
//@ControllerAdvice
//public class InterceptResponse implements ResponseBodyAdvice<Object> {
//
//    @Override
//    public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
//        return true;
//    }
//
//    @Nullable
//    @Override
//    public Object beforeBodyWrite(@Nullable Object body, MethodParameter methodParameter, MediaType mediaType, Class<
//            ? extends HttpMessageConverter<?>> aClass, ServerHttpRequest serverHttpRequest,
//                                  ServerHttpResponse serverHttpResponse) {
//        String path = serverHttpRequest.getURI().getPath();
//        Set<String> notAllowedPathsSet = GuaranteeGlobalConstant.NOT_ALLOWED_PATHS_SET.stream().filter(path::contains).collect(Collectors.toSet());
//        if (!CollectionUtils.isEmpty(notAllowedPathsSet)) {
//            //证明是不需要加解密的路径，放行
//            return body;
//        }
//        if (body instanceof Result) {
//            JSONObject jsonBody = (JSONObject) JSONObject.toJSON(body);
//            DesensitizeUtil.analyzeJson(jsonBody, GuaranteeGlobalConstant.ENCRYPT_FLAG);
//            return jsonBody.toJavaObject(Result.class);
//        }
//        return body;
//    }
//}